package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 服务库存出库流水记录
 * </p>
 *
 * @author linan
 * @date 2022-09-23
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceInventoryOutFlowOutStockTypeEnum", description = "出库类型 #{EXHIBITION:展会出库;DAILY:日常出库;DAMAGE:损坏出库;ORDER:订单出库;BORROW:借用出库-枚举")
public enum ServiceInventoryOutFlowOutStockTypeEnum implements BaseEnum {

    /**
     * EXHIBITION="展会出库"
     */
    EXHIBITION("展会出库"),
    /**
     * DAILY="日常出库"
     */
    DAILY("日常出库"),
    /**
     * DAMAGE="损坏出库"
     */
    DAMAGE("损坏出库"),
    /**
     * ORDER="订单出库"
     */
    ORDER("订单出库"),
    /**
     * BORROW="借用出库"
     */
    BORROW("借用出库"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceInventoryOutFlowOutStockTypeEnum match(String val, ServiceInventoryOutFlowOutStockTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceInventoryOutFlowOutStockTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceInventoryOutFlowOutStockTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "EXHIBITION,DAILY,DAMAGE,ORDER,BORROW", example = "EXHIBITION")
    public String getCode() {
        return this.name();
    }

}
